/*
    Copyright 2006 Andrew Wilkinson <andrew@indiegigs.co.uk>

    This file is part of libgp2x.

    libgp2x is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    libgp2x is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with libgp2x; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include "gp2x_internal.h"

unsigned short* GP2x_screen_0;
unsigned short* GP2x_screen_1;

void GP2x_video_init() {
    SDL_screen = SDL_SetVideoMode(320, 240, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
    if(SDL_screen == NULL) {
        fprintf(stderr, "Unable to set 320x240 video: %s\n", SDL_GetError());
        exit(1);
    }
    SDL_LockSurface(SDL_screen);
}

void GP2x_flip_unsync() {
static int starttime = 0;
static int framecount = 0;

    SDL_UnlockSurface(SDL_screen);
    SDL_Flip(SDL_screen);
    SDL_LockSurface(SDL_screen);

    if(starttime == 0) {
        starttime = SDL_GetTicks();
    }
    framecount++;
    if(SDL_GetTicks() - starttime > 10000) {
        printf("Average frame rate %ffps.\n", framecount/((SDL_GetTicks() - starttime) / 1000.0));
        starttime = SDL_GetTicks();
        framecount = 0;
    }
}

void GP2x_video_hsync() {
}

void GP2x_video_vsync() {
}
